package com.ocom.webapi.controller;


import com.ocom.common.constant.WebApiServiceUrl;
import com.ocom.common.request.payconfig.GetUserSignInfoListRequest;
import com.ocom.common.request.payconfig.SignatureListRequest;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.security.utils.SecurityUtils;
import com.ocom.webapi.feign.PayConfigClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SignController {
    @Autowired
    private PayConfigClientService payConfigClientService;

    @PostMapping(WebApiServiceUrl.Url_getUserSignInfoList)
    public Result getUserSignInfoList(@RequestBody GetUserSignInfoListRequest request){
        Long role = SecurityUtils.getYoCiUser().getRole();
        if (role != 0l && role != 1l) {
            return ResultUtil.success();
        }
        return this.payConfigClientService.getUserSignInfoList(request);
    }

    @PostMapping(WebApiServiceUrl.URL_gzhSignRecords)
    public Result gzhSignRecords(@RequestBody SignatureListRequest request){
        Long comId = SecurityUtils.getYoCiUser().getComId();
        request.setComId(comId);
        return this.payConfigClientService.gzhSignRecords(request);
    }
}
